-
Notifications
You must be signed in to change notification settings - Fork 250
feat: [iceberg] Native scan by serializing FileScanTasks to iceberg-rust #2528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mbutrovich
wants to merge
130
commits into
apache:main
Choose a base branch
from
mbutrovich:iceberg-rust
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2528 +/- ##
============================================
+ Coverage 56.12% 59.61% +3.49%
- Complexity 976 1530 +554
============================================
Files 119 167 +48
Lines 11743 14883 +3140
Branches 2251 2503 +252
============================================
+ Hits 6591 8873 +2282
- Misses 4012 4738 +726
- Partials 1140 1272 +132 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
|
It is promising! |
227332c to
6966a12
Compare
# Conflicts: # native/Cargo.lock # spark/src/main/scala/org/apache/comet/rules/CometScanRule.scala
…eberg version back to 1.8.1 after hitting known segfaults with old versions.
This was referenced Oct 15, 2025
liurenjie1024
pushed a commit
to apache/iceberg-rust
that referenced
this pull request
Oct 16, 2025
## Which issue does this PR close? - Part of #1749. ## What changes are included in this PR? - Change `ArrowReaderBuilder::new` to be `pub` instead of `pub(crate)`. ## Are these changes tested? - No new tests for this. Currently being used in DataFusion Comet: apache/datafusion-comet#2528
# Conflicts: # docs/source/user-guide/latest/configs.md # native/Cargo.lock # native/Cargo.toml # native/core/Cargo.toml
# Conflicts: # spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala # spark/src/main/scala/org/apache/spark/sql/comet/operators.scala
# Conflicts: # native/Cargo.toml # spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
# Conflicts: # spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
11 tasks
Contributor
Author
|
Added the 1.10.0.diff from #2709 and after a day of hacking: |
…tSystemFunctionPushDownDQL > testTruncateFunctionOnUnpartitionedTable() in Spark extensions tests.
liurenjie1024
added a commit
to apache/iceberg-rust
that referenced
this pull request
Nov 13, 2025
…chTransformer (#1821) ## Which issue does this PR close? Partially address #1749. ## What changes are included in this PR? This PR adds partition spec handling to `FileScanTask` and `RecordBatchTransformer` to correctly implement the Iceberg spec's "Column Projection" rules for fields "not present" in data files. ### Problem Statement Prior to this PR, `iceberg-rust`'s `FileScanTask` had no mechanism to pass partition information to `RecordBatchTransformer`, causing two issues: 1. **Incorrect handling of bucket partitioning**: Couldn't distinguish identity transforms (which should use partition metadata constants) from non-identity transforms like bucket/truncate/year/month (which must read from data file). For example, `bucket(4, id)` stores `id_bucket = 2` (bucket number) in partition metadata, but actual `id` values (100, 200, 300) are only in the data file. iceberg-rust was incorrectly treating bucket-partitioned source columns as constants, breaking runtime filtering and returning incorrect query results. 2. **Field ID conflicts in add_files scenarios**: When importing Hive tables via `add_files`, partition columns could have field IDs conflicting with Parquet data columns. Example: Parquet has field_id=1→"name", but Iceberg expects field_id=1→"id" (partition). Per spec, the correct field is "not present" and requires name mapping fallback. ### Iceberg Specification Requirements Per the Iceberg spec (https://iceberg.apache.org/spec/#column-projection), when a field ID is "not present" in a data file, it must be resolved using these rules: 1. Return the value from partition metadata if an **Identity Transform** exists 2. Use `schema.name-mapping.default` metadata to map field id to columns without field id 3. Return the default value if it has a defined `initial-default` 4. Return null in all other cases **Why this matters:** - **Identity transforms** (e.g., `identity(dept)`) store actual column values in partition metadata that can be used as constants without reading the data file - **Non-identity transforms** (e.g., `bucket(4, id)`, `day(timestamp)`) store transformed values in partition metadata (e.g., bucket number 2, not the actual `id` values 100, 200, 300) and must read source columns from the data file ### Changes Made 1. **Added partition fields to `FileScanTask`** (`scan/task.rs`): - `partition: Option<Struct>` - Partition data from manifest entry - `partition_spec: Option<Arc<PartitionSpec>>` - For transform-aware constant detection - `name_mapping: Option<Arc<NameMapping>>` - Name mapping from table metadata 2. **Implemented `constants_map()` function** (`arrow/record_batch_transformer.rs`): - Replicates Java's `PartitionUtil.constantsMap()` behavior - Only includes fields where transform is `Transform::Identity` - Used to determine which fields use partition metadata constants vs. reading from data files 3. **Enhanced `RecordBatchTransformer`** (`arrow/record_batch_transformer.rs`): - Added `build_with_partition_data()` method to accept partition spec, partition data, and name mapping - Implements all 4 spec rules for column resolution with identity-transform awareness - Detects field ID conflicts by verifying both field ID AND name match - Falls back to name mapping when field IDs are missing/conflicting (spec rule #2) 4. **Updated `ArrowReader`** (`arrow/reader.rs`): - Uses `build_with_partition_data()` when partition information is available - Falls back to `build()` when not available 5. **Updated manifest entry processing** (`scan/context.rs`): - Populates partition fields in `FileScanTask` from manifest entry data ### Tests Added 1. **`bucket_partitioning_reads_source_column_from_file`** - Verifies that bucket-partitioned source columns are read from data files (not treated as constants from partition metadata) 2. **`identity_partition_uses_constant_from_metadata`** - Verifies that identity-transformed fields correctly use partition metadata constants 3. **`test_bucket_partitioning_with_renamed_source_column`** - Verifies field-ID-based mapping works despite column rename 4. **`add_files_partition_columns_without_field_ids`** - Verifies name mapping resolution for Hive table imports without field IDs (spec rule #2) 5. **`add_files_with_true_field_id_conflict`** - Verifies correct field ID conflict detection with name mapping fallback (spec rule #2) 6. **`test_all_four_spec_rules`** - Integration test verifying all 4 spec rules work together ## Are these changes tested? Yes, there are 6 new unit tests covering all 4 Iceberg spec rules. This also resolved approximately 50 Iceberg Java tests when running with DataFusion Comet's experimental apache/datafusion-comet#2528 PR. --------- Co-authored-by: Renjie Liu <[email protected]>
# Conflicts: # native/core/Cargo.toml # spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


This PR introduces a new approach for integrating Apache Iceberg with Comet using iceberg-rust, enabling fully-native Iceberg table scans without requiring changes to upstream Iceberg Java code.
Rationale for this change
I was inspired by @RussellSpitzer's recent talk and wanted to revisit the abstraction layer at which Comet integrates with Iceberg.
Our current
iceberg_compatapproach requires code changes in Iceberg Java to integrate with Parquet reader instantiation, creating a tight coupling between Comet and Iceberg. This PR instead works at theFileScanTasklayer after Iceberg's planning phase is complete. This enables fully-native Iceberg scans (similar to ournative_datafusionscans) without any changes in upstream Iceberg Java code.All catalog access and planning continues to happen through Spark's Iceberg integration (unchanged), but file reading is delegated to iceberg-rust, which provides better parallelism and integrates naturally with Comet's native execution engine.
What changes are included in this PR?
This implementation follows a similar pattern to
CometNativeScanExecfor regular Parquet files, but extracts and serializes Iceberg'sFileScanTaskobjects:Scala/JVM Side:
CometIcebergNativeScanExecoperator that replaces Spark's IcebergBatchScanExecFileScanTaskobjects from Iceberg's planning outputNative/Rust Side:
IcebergScanExecoperator that consumes serializedFileScanTaskobjectsFileIOandArrowReaderto read data filesHow are these changes tested?
CometIcebergNativeSuitewith basic scenarios, but also a number of challenging situations from the Iceberg Java test suiteCometFuzzIcebergSuitethat we can adapt to Iceberg-specific logicIcebergReadFromS3Suiteto test passing basic S3 credentialsBenefits over
iceberg_compatnative_datafusion, not constrained by Iceberg Java's reader designArrowReaderCurrent Limitations & Open Questions
ArrowReaderOptionsto benefit from previous work in Arrow-rs Support different TimeUnits and timezones when reading Timestamps from INT96 arrow-rs#7285iceberg_compatcode and its Iceberg Java entanglementRelated Work
Slides from the 10/9/25 Iceberg-Rust community call: iceberg-rust.pdf